package com.lfd.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lfd.mapper.ICarProductMapper;
import com.lfd.service.ICarProductService;
import com.lfd.util.UserUtil;
import com.lfd.entity.CarProduct;
import com.lfd.vo.CarProductVo;

@Service
public class ICarProductServiceImpl implements ICarProductService {
	@Autowired
	private ICarProductMapper icarProductMapper;

	@Override
	public List<CarProductVo> selectCarProductVos(CarProduct carProduct, Integer page, Integer limit) {
		Long id = UserUtil.getId();
		 
	    carProduct.setUserId(id);
		List<CarProductVo> selectCarProductVos = icarProductMapper.selectCarProductVos(id,carProduct,(page-1)*limit,limit);
		return selectCarProductVos;
	}

	@Override
	public int queryCount() {
		 int count = icarProductMapper.queryCount();
		 return count;
	}

	@Override
	public void insertProduct(CarProduct carProduct) {
		icarProductMapper.insertProduct(carProduct);
	}

	@Override
	public void updateProduct(CarProduct carProduct) {
		carProduct.setIsDelete(false);
		icarProductMapper.updateProduct(carProduct);
	}

	
    //前台移除购物车
	@Override
	public void deleteById(Long carId) {
		icarProductMapper.deleteById(carId);
	}
     //前台清空购物车

	@Override
	public void qingkong(CarProduct carProduct) {
             icarProductMapper.qingkong(carProduct);
		
	}
	
	



}
